function getRandomColor() {
  const rgb = []
  for (let i = 0; i < 6; ++i) {
    let color = Math.floor(Math.random() * 256).toString(16)
    color = color.length == 1 ? '0' + color : color
    rgb.push(color)
  }
  return '#' + rgb.join('')
}

Page({
  onReady: function (res) {
    this.videoContext = wx.createVideoContext('myVideo')
  },
  inputValue: '',
  data: {
    src: '',
    // 弹幕
    danmuList: [
      {
        text: '加油',
        color: '#ff0000',
        time: 1
      },
      {
        text: '辽宁yyds',
        color: '#ff00ff',
        time: 3
      },
      {
        text: '辽宁加油',
        color: '#ff00ff',
        time: 3
      }
    ],
    // videoData
    videoData:[
      {
        userImg:"/image/微信图片_20211025100754.jpg",
        userName:"宋晓云",
        watchPeopleNum:'1.5万',
        src:"https://vd3.bdstatic.com/mda-mk3kbr7xhipswi7w/cae_h264_nowatermark/1636035945753515240/mda-mk3kbr7xhipswi7w.mp4?v_from_s=hkapp-haokan-hbe&auth_key=1636083786-0-0-c8804b16285c6c1c24dd99c2ee84f072&bcevod_channel=searchbox_feed&pd=1&vt=1&cd=0&watermark=0&did=&logid=0786518833&vid=11775292219248473864&pt=0&appver=&model=&cr=0&abtest=peav_l52&sle=1&sl=1121&split=960661",
        brife:"不一样的墨刀-给你的期待",
        time:"08月13日",
      },
      {
        userImg:"/image/微信图片_20211025100754.jpg",
        userName:"宋晓云",
        watchPeopleNum:'1.5万',
        src:"https://vd3.bdstatic.com/mda-mhp3udhui38yej3v/cae_h264/1629773448751837704/mda-mhp3udhui38yej3v.mp4?v_from_s=hkapp-haokan-hbe&auth_key=1636096162-0-0-ad26e5df13563e7d452f72f72c7098c9&bcevod_channel=searchbox_feed&pd=1&vt=1&cd=0&watermark=0&did=&logid=2362458288&vid=7536915719699739134&pt=0&appver=&model=&cr=0&abtest=peav_l52&sle=1&sl=472&split=451600",
        brife:"不一样的墨刀-给你的期待",
        time:"08月13日",
      },
      {
        userImg:"/image/微信图片_20211025100754.jpg",
        userName:"宋晓云",
        watchPeopleNum:'1.5万',
        src:"https://vd3.bdstatic.com/mda-mhg2471k1v6jmpz5/cae_h264_nowatermark/1629168044736261069/mda-mhg2471k1v6jmpz5.mp4?v_from_s=hkapp-haokan-tucheng&auth_key=1636096246-0-0-35bee5e21870e7677e5fc6d6943722ca&bcevod_channel=searchbox_feed&pd=1&vt=1&cd=0&watermark=0&did=&logid=2445882932&vid=4802630566375487614&pt=0&appver=&model=&cr=0&abtest=peav_l52&sle=1&sl=641&split=582044",
        brife:"不一样的墨刀-给你的期待",
        time:"08月13日",
      }
    ]
  },
  // 视频播放错误执行的回调
  videoErrorCallback: function (e) {
    console.log('视频错误信息:')
    console.log(e.detail.errMsg)
  },
  // 跳转到购物车
  toShopCar(){
    wx.switchTab({
      url: '/pages/shopcar/order',
    })
  },
  onLoad(){
    wx.setNavigationBarTitle({
      title: '直播带货',
    })
    wx.setNavigationBarColor({
      backgroundColor: '#ff5347',
      frontColor: '#ffffff',
    })
  }
})